<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>CaptureImages</title>
    <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
    <script src="https://cdn.bootcss.com/viewerjs/1.0.0/viewer.min.js"></script>
    <link href="https://cdn.bootcss.com/viewerjs/1.0.0/viewer.min.css" rel="stylesheet">
    <script  src={{ url_for('static', filename='js/rc-viewer.js') }}></script>
    <script src="https://unpkg.com/babel-core@5.8.38/browser.min.js"></script>
</head>
<style>
    img{
        width:  200px;
    }
</style>
<body>
    <form method=POST action="{{ url_for('getdate') }}">
        <input type="date" name="date" placeholder="YYYY-DD-MM" id="aDate" >
        <input type="submit" class="button -green center">
        <h1>{{sdate}}</h1>
    </form>

    <div id="example"></div>
    <script type="text/babel">
    var rcRef = function(e){
     console.log(e.getViewer())
    }
    console.log(RcViewer)
     ReactDOM.render(
        <RcViewer ref={rcRef}>
          {% for image_name in image_names %}
            <img src="{{ url_for('static', filename='images/'+sdate+'/'+image_name) }}" title="{{image_name}}" alt="{{image_name}}"/>
           {% endfor %}
           {% for video_name in video_names %}
            <video src="{{ url_for('static', filename='images/'+sdate+'/'+video_name) }}" controls="controls" title="{{video_name}}" alt="{{video_name}}" />
            {% endfor %}
        </RcViewer>,
        document.getElementById('example')
      );
      
    </script>
</body>



<script type="text/javascript">
    var mydateInput = document.getElementById("aDate");
    var now = new Date();
    var day = ("0" + now.getDate()).slice(-2);
	//格式化月，如果小于9，前面补0
	var month = ("0" + (now.getMonth() + 1)).slice(-2);
	//拼装完整日期格式
	var dateString = now.getFullYear()+"-"+(month)+"-"+(day) ;
    mydateInput.value = dateString;
</script>
</html>
